import { _decorator, Component, Label, Node, RichText } from 'cc';
import { BasicUI } from '../../Init/Basic/BasicUI';
import { UISystem } from '../../Init/SystemUI/UISystem';
import { UIEnum } from '../../Init/SystemUI/UIEnum';
const { ccclass, property } = _decorator;

export enum TipClosedMode {
    Close,Ad
}

export interface TipUIData {
    tip:string;
    showMode:"close"|"ad";
    closeCallback:Function;
}

@ccclass('TipUI')
export class TipUI extends BasicUI {
    @property(Node)
    protected BtnNode: Node = null;
    @property(RichText)
    protected tip: RichText = null;
    private dat:TipUIData;
    public show(d:TipUIData) {
        super.show(d);
        this.dat = d;
        this.tip.string = d.tip;
        this.BtnNode.active = d.showMode == "ad";
        
    }
    public hide() {
        super.hide();
    }

    private onClosed() {
        this.dat.closeCallback(TipClosedMode.Close);
        UISystem.hideUI(UIEnum.TipUI);
    }

    private onAd() {
        this.dat.closeCallback(TipClosedMode.Ad);
        UISystem.hideUI(UIEnum.TipUI);
    }
}

